##
## Statistical model
## Recovering policy positions from political speeches:
## a sentiment analysis approach
##

model{
  for(i in 1:N){ ##loop over legislators
    for(j in 1:M){ ##loop over topics
      y[i,j] ~ dbin(p[i,j], n[i,j])
      logit(p[i,j]) <- alpha[j] + beta[j] * theta[i]
    }
  }

  ##priors over alpha
  for(j in 1:M){
    alpha[j] ~ dnorm(0,1)
  }

  ##priors over beta
  for(j in 1:M){
    beta[j] ~ dnorm(0,1)
  }

  ##priors over theta
  theta[1] ~ dnorm(0, 1)T(.9, 1.1) #psdb
  theta[2] ~ dnorm(0, 1)T(-1.1, -.9) #pt
  for(i in 3:N){
    theta[i] ~ dnorm(0, 1)
  }
}
